Skip to content

fix(normal-distribution): prevent ±infinity samples from Box-Muller - #184

Merged
JimmyMAndersson merged 1 commit into
mainfrom
fix/178-normal-dist-sample-inf
May 24, 2026
Merged

fix(normal-distribution): prevent ±infinity samples from Box-Muller#184
JimmyMAndersson merged 1 commit into
mainfrom
fix/178-normal-dist-sample-inf

Conversation

@JimmyMAndersson

Copy link
Copy Markdown
Owner

Sample u1 and u2 from the open interval (0, 1) to avoid log(0) = -∞. The batch method now consumes both outputs of each Box-Muller pair, halving the number of transcendental function calls.

Fixes: #178

Sample u1 and u2 from the open interval (0, 1) to avoid log(0) = -∞.
The batch method now consumes both outputs of each Box-Muller pair,
halving the number of transcendental function calls.

Fixes: #178
@JimmyMAndersson JimmyMAndersson self-assigned this May 24, 2026
@JimmyMAndersson JimmyMAndersson added the bug Something isn't working label May 24, 2026
@JimmyMAndersson
JimmyMAndersson merged commit a8739f7 into main May 24, 2026
5 checks passed
@JimmyMAndersson
JimmyMAndersson deleted the fix/178-normal-dist-sample-inf branch May 24, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

# NormalDistribution.sample() and sample(_:) can return ±infinity due to log(0)

1 participant